package com.jingyu.sport.controllers;

import com.jingyu.sport.domian.FirstApp;
import com.jingyu.sport.services.FirstAppService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/firstApp")
public class FirstAppController {


    @Autowired
    private FirstAppService firstAppService;



    @RequestMapping("/add")
    // "http://127.0.0.1:8081/firstApp/add?name=testName&address=testAddress"
    String add(FirstApp mode){
        firstAppService.add(mode);
        return "success";
    }

    @RequestMapping("/remove")
    //"http://127.0.0.1:8081/firstApp/remove?id=1"
    String remove(int id){
        firstAppService.remove(id);
        return "success";
    }

    @RequestMapping("/update")
    //"http://127.0.0.1:8081/firstApp/update?name=testName&address=testAddress1111&id=4"
    String update(FirstApp mode){
        firstAppService.update(mode);
        return "success";
    }

    @RequestMapping("/query")
    //curl "http://127.0.0.1:8081/firstApp/query"
    List<FirstApp> query(){
        return firstAppService.query();
    }

    @RequestMapping("get")
    //curl "http://127.0.0.1:8081/firstApp/get?id=4"
    FirstApp get(int id){
        return firstAppService.get(id);
    }

}
